package com.topgay.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.topgay.domain.Member;
import com.topgay.domain.Message;

@Repository
public class MessageDAOImpl implements MessageDAO{


	@Autowired
	private SqlSessionTemplate session;
	

	@Override
	public int insertMessage(Message message) throws SQLException {
		return session.insert("message.insertMessage", message);
	}

	@Override
	public Member selectMemberById(String id) throws SQLException {

		return session.selectOne("message.selectMemberById", id);
	}

	@Override
	public List<Member> getMemberList() throws SQLException {
		return session.selectList("message.selectMemberList");
	}

	@Override
	public List<Message> getMessageById(Map map) throws Exception {
		return session.selectList("message.selectMessageById", map);
	}

	
	@Override
	public List<Message> getSendMessageById(Map map) throws Exception {
		return session.selectList("message.selectSendMessageById", map);
	}

	@Override
	public int selectTotalContent() {
		return session.selectOne("message.selectTotalContent");
	}

	@Override
	public Message selectContentByNum(int num) throws SQLException {
		return session.selectOne("message.selectContentByNum", num);
	}

	@Override
	public int deleteMessageByNum(int num) throws SQLException {
		return session.delete("message.deleteMessageByNum", num);
	}

	@Override
	public int getTotalMessageNumReceive(String id) throws SQLException {
		return session.selectOne("message.selectTotalMessageNumByIdReceiveBox", id);
	}

	@Override
	public int getTotalMessageNumSend(String id) throws SQLException {
		return session.selectOne("message.selectTotalMessageNumByIdSendBox", id);
	}
	
	
	
	
}
